import hyRequest from '@/service'

// 获取rsa公钥
export const getPublicKey = () => {
  return hyRequest.get({
    url: '/getPublicKey'
  })
}

// 获取手机验证码
export const getPhoneCode = (userPhone: string) => {
  return hyRequest.post({
    url: `/send/sendPhoneCode/${userPhone}`,
    isShowMessage: true
  })
}

// 获取邮件验证码
export const getEmailCode = (emailNumber: string) => {
  return hyRequest.post({
    url: `/send/sendMail/${emailNumber}`,
    isShowMessage: true
  })
}

// 获取用户信息
export const getPersonalInfo = () => {
  return hyRequest.get({
    url: '/getPersonalInfo'
  })
}

// 获取用户菜单数据
export const getMenuInfoById = () => {
  return hyRequest.get({
    url: '/getMenuInfoById'
  })
}

// 退出登录
export const reqLogout = () => {
  return hyRequest.post({
    url: '/logout'
  })
}

// 修改密码
export const reqUpdatePwd = (encryptStr: string) => {
  return hyRequest.post({
    url: '/user/updatePassword',
    data: { encryptStr },
    isShowMessage: true
  })
}

// 二级认证
export const reqSecondAuth = (encryptStr: string) => {
  return hyRequest.post({
    url: '/openSafe',
    data: { encryptStr },
    isShowMessage: true
  })
}

// 图片上传
export const reqUploadFile = (data: FormData) => {
  return hyRequest.post({
    url: `/file/uploadImage`,
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data,
    isShowMessage: true
  })
}
